Skip to content

feat: Enable max-amount and Perps/Predict withdraw flows for Money Account vault deposit via post-Relay path#9404

Open
OGPoyraz wants to merge 9 commits into
mainfrom
ogp/max-ma-deposit
Open

feat: Enable max-amount and Perps/Predict withdraw flows for Money Account vault deposit via post-Relay path#9404
OGPoyraz wants to merge 9 commits into
mainfrom
ogp/max-ma-deposit

Conversation

@OGPoyraz

@OGPoyraz OGPoyraz commented Jul 7, 2026

Copy link
Copy Markdown
Member

Explanation

Previously, Money Account vault deposits were always embedded atomically in the Relay batch as a fixed-amount EXACT_OUTPUT call. This breaks for two cases:

  1. Max-amount MoneyAccountDeposit — the exact mUSD amount settled by Relay is only known after the bridge completes, so the vault deposit amount cannot be predetermined at quote time.
  2. Perps/Predict withdrawals to mUSD on Monad — these are post-quote EXACT_INPUT flows where the settled amount is likewise only available after Relay completes.

This PR introduces a post-Relay vault deposit path: for these cases, Relay bridges mUSD directly to the Money Account (redirecting the recipient to transaction.txParams.from), and once Relay settles successfully a separate sponsored vault deposit is submitted with the actual on-chain settled amount.

Changes

transaction-pay-controller

  • Add isPerpsWithdrawTransaction utility (mirrors existing isPredictWithdrawTransaction) to detect perps withdrawals by top-level or nested transaction type.
  • Add isPostRelayMoneyAccountVaultDeposit predicate in relay-post-ma-vault — returns true for max-amount MA deposits and for Perps/Predict withdrawals targeting mUSD on Monad.
  • In relay-quotes (getSingleQuote): when the predicate is true, override request.recipient to txParams.from so Relay delivers mUSD to the Money Account, and skip atomic embedding of the vault deposit.
  • In relay-submit (executeSingleQuote): after a successful Relay completion, call submitPostRelayVaultDeposit to deposit the settled mUSD into the vault. Skip the paymentOverride batch-prepend path for these flows.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Touches core Relay quote/submit and fund routing (recipient override, skipping atomic vault and paymentOverride); incorrect predicate or amount resolution could mis-route mUSD or under-deposit to the vault.

Overview
Adds a post-Relay vault deposit path when the settled mUSD amount is unknown at quote time: Relay delivers mUSD to the Money Account first, then a separate sponsored vault deposit runs after completion.

Detection: New isPerpsWithdrawTransaction (nested-aware, like Predict) and exported isPostRelayMoneyAccountVaultDeposit — true for max-amount Money Account deposits and for Perps/Predict withdrawals whose target is mUSD on Monad.

Quote (relay-quotes): When the predicate matches, Relay recipient is set to transaction.txParams.from and atomic vault embedding is skipped (bridge-only quote).

Submit (relay-submit): On successful Relay completion, calls existing submitPostRelayVaultDeposit and returns its hash (fallback to Relay target hash). Skips the paymentOverride batch-prepend path for these flows.

Tests and changelog updated; no new public API beyond the new utilities/predicate.

Reviewed by Cursor Bugbot for commit 1a997ab. Bugbot is set up for automated code reviews on this repo. Configure here.

@OGPoyraz OGPoyraz changed the title feat: Enable max amount crypto deposit for MoneyAccountDeposit feat: Enable max-amount and Perps/Predict withdraw flows for Money Account vault deposit via post-Relay path Jul 7, 2026
@OGPoyraz OGPoyraz marked this pull request as ready for review July 7, 2026 12:21
@OGPoyraz OGPoyraz requested review from a team as code owners July 7, 2026 12:21
@OGPoyraz OGPoyraz temporarily deployed to default-branch July 7, 2026 12:21 — with GitHub Actions Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1a997ab. Configure here.

log(
'Money Account vault deposit: submitting Relay bridge only; vault deposit runs post-completion',
);
} else if (quote.request.paymentOverride) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-relay skips post-quote prepend

High Severity

When isPostRelayMoneyAccountVaultDeposit is true, submitTransactions only logs and skips the paymentOverride and post-quote branches that prepend required transactions to the Relay batch. Predict withdrawals to mUSD on Monad still need the original post-quote transaction executed before Relay can spend source funds, so submission can proceed without unlocking tokens.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1a997ab. Configure here.

log(
'Money Account vault deposit: skipping atomic embedding; mUSD settles to the Money Account for a post-Relay vault deposit',
);
} else if (shouldProcessTransactions) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-relay drops Predict refundTo

Medium Severity

For post-Relay Money Account vault quotes, getSingleQuote logs and skips the later branches that set body.refundTo from request.refundTo. Predict withdrawals to mUSD on Monad use that refund address so failed Relay attempts return funds to the Safe proxy instead of the EOA.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1a997ab. Configure here.

@matthewwalsh0 matthewwalsh0 requested a review from dan437 July 7, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant